import type { AlarmConfig } from './model';

import type { ID, IDS, PageQuery } from '#/api/common';

import { requestClient } from '#/api/request';

/**
 * 告警配置列表
 * @param params
 * @returns data
 */
export function getAlarm(params?: PageQuery) {
  return requestClient.get<AlarmConfig>('/iot/alarm/page', { params });
}

/**
 * 产品下拉
 * @returns []
 */

export function productSelect() {
  return requestClient.get('/iot/product/select');
}

/**
 * 设备下拉
 * @returns []
 */

export function deviceSelect(id: number) {
  return requestClient.get(`/iot/device/select?productId=${id}`);
}
/**
 *物模型功能模块下拉数据源
 * @param id
 * @returns []
 */
export function thingModelSelect(id: number) {
  return requestClient.get(`/iot/thingModel/block/select?productId=${id}`);
}
/**
 * 属性下拉数据源
 * @param id
 * @returns []
 */
export function propertySelect(id: number) {
  return requestClient.get(`/iot/thingModel/item/list?blockId=${id}`);
}

/**
 * 新增告警
 * @param data
 * @returns  []
 */
export function addAlarmConfig(data: any) {
  return requestClient.postWithMsg(`/iot/alarm/add`, data);
}
/**
 * 修改告警
 * @param data
 * @returns  []
 */
export function updateAlarmConfig(data: any) {
  return requestClient.postWithMsg(`/iot/alarm/update`, data);
}

/**
 * 删除告警
 * @param id
 */
export function removeAlarmConfig(id: ID | IDS) {
  return requestClient.postWithMsg(`/iot/alarm/remove?id=${id}`);
}

/**
 * 告警详情
 * @param id
 * @returns
 */

export function AlarmConfigDetail(id: number) {
  return requestClient.get(`/iot/alarm/detail?id=${id}`);
}
/**
 * 获取mqtt详细信息
 * @param id
 * @returns
 */

export function linklnfos(id: ID | IDS) {
  return requestClient.get(`/iot/device/linkInfos?deviceId=${id}`);
}
